package Test1.GeneralFunction;

import Test1.HCNetSDK;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by panting6 on 2021/8/12.
 */
public class CaptureJPEGPicture {
    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
    public void captureJPEGPicture(int lUserID, int iChannelNum,short picsize)
    {
        HCNetSDK.NET_DVR_JPEGPARA lpJpegPara = new HCNetSDK.NET_DVR_JPEGPARA();
        lpJpegPara.wPicQuality = 1;
        lpJpegPara.wPicSize = picsize;
        SimpleDateFormat sf = new SimpleDateFormat("yyyymmddHHmmss");
        String newName = sf.format(new Date());
        if(!hCNetSDK.NET_DVR_CaptureJPEGPicture(lUserID,iChannelNum,lpJpegPara,".\\pic\\" + "Capture"+newName + ".jpg"))
        {
            System.out.println("设备抓图失败，错误码：" + hCNetSDK.NET_DVR_GetLastError());
        }
        else{
            System.out.println("设备抓图成功，保存在pic文件夹中");
        }
    }
}
